#include<bits/stdc++.h>
using namespace std;
#define ll long long

bool cmp(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
}

int main() {
    int l, m;
    cin >> l >> m;
    vector<pair<int, int>> vec(m);
    for (int i = 0; i < m; i++) {
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(), vec.end(), cmp);
    vector<pair<int, int>> subway;
    subway.push_back(vec[0]);
    for (int i = 1; i < m; i++) {
        if (vec[i].first <= subway.back().second) {
            subway.back().second = max(subway.back().second, vec[i].second);
        }
        else {
            subway.push_back(vec[i]);
        }
    }
    int cnt = 0;
    for (int i = 0; i < subway.size(); i++) {
        cnt += subway[i].second - subway[i].first + 1;
    }
    cout << l + 1 - cnt << endl;
    return 0;
}